package com.whut.controller;


import com.whut.model.*;
import com.whut.service.MotorService;
import com.whut.v_model.PointAndProject;
import com.whut.v_model.CTPInfo;
import com.whut.v_model.ProblemCollectDetail;
import com.whut.v_model.ProjectNum;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/motor")
@CrossOrigin("*")
public class MotorController {
    @Resource
    private MotorService motorService;
    @ResponseBody
    @PostMapping("/getAllContractInfoByReserve1")
    public List<Object> getAllContractInfoByReserve1(String reserve1, String contractId){
        System.out.println(contractId);
        return motorService.getAllContractInfoByReserve1(reserve1,contractId);
    }

    @ResponseBody
    @PostMapping("/getSecondChildsByNode")
    public List<ParPrefixSystem> getSecondChildsByNode(Integer preNum){
        return motorService.getSecondChildsByNode(preNum);
    }

    @ResponseBody
    @PostMapping("/getProblemNumByForthId")
    public Integer getProblemNumByForthId(Integer fourthId,String contractId){
        return motorService.getProblemNumByForthId(fourthId,contractId);
    }

    @ResponseBody
    @PostMapping("/getItemByNameAndDepth")
    public List<Problemcollect> getItemByNameAndDepth(String parameterName,Integer nodeDepth,String contractId){
        return motorService.getItemByNameAndDepth(parameterName,nodeDepth,contractId);
    }


    @ResponseBody
    @PostMapping("/getProblemsByForthId")
    public List<Problemcollect> getProblemsByForthId(Integer fourthId){
        return motorService.getProblemsByForthId(fourthId);
    }

    /*ss*/
    @ResponseBody
    @PostMapping("/getRiskWarning")
    public List<ProblemCollectDetail> getRiskWarning(Integer contractId){
        return motorService.getRiskWarning(contractId);
    }

    /*ss*/
    @ResponseBody
    @PostMapping("/GetProjectRank")
    public List<PointAndProject> GetProjectRank(Integer taskId, String startTime, String endTime){
        return motorService.GetProjectRank(taskId,startTime,endTime);
    }

    /*ss*/
    @ResponseBody
    @PostMapping("/getNewProjectRank")
    public List<PointAndProject> getNewProjectRank(){
        return motorService.getNewProjectRank();
    }

    /*ss*/
    @ResponseBody
    @PostMapping("/getAllTaskInfo")
    public Object getAllTaskInfo(Integer contractId){
        return motorService.getAllTaskInfo(contractId);
    }

    /*ss*/
    @ResponseBody
    @PostMapping("/getAllTask")
    public Object getAllTask(){
        return motorService.getAllTask();
    }

    /*ss*/
    @ResponseBody
    @PostMapping("/getNewProjectRankByContract")
    public List<PointAndProject> getNewProjectRankByContract(Integer contractId){
        return motorService.getNewProjectRankByContract(contractId);
    }


    /*ss*/
    @ResponseBody
    @PostMapping("/getNewProjectOnlyByTime")
    public List<PointAndProject> getNewProjectOnlyByTime(String startTime, String endTime){
        return motorService.getNewProjectOnlyByTime(startTime,endTime);
    }

    /*wxd*/
    @ResponseBody
    @PostMapping("/getProblemByProject")
    public List<ProblemCollectDetail> getProblemByProject(Integer checkId,Integer projectId){
        return motorService.getProblemByProject(checkId,projectId);
    }
    @ResponseBody
    @PostMapping("/getMaxTaskId")
    public  Integer getMaxTaskId(Integer contractId){
        return motorService.getMaxTaskId(contractId);
    }

    @ResponseBody
    @PostMapping("/getCheckBytaskId")
    public  List<ContractCheckTask> getCheckBytaskId(Integer taskId){
        return motorService.getCheckBytaskId(taskId);
    }

    @ResponseBody
    @PostMapping("/getProblemsBycheckId")
    public  List<Problemcollect> getProblemsBycheckId(Integer checkId){
        return motorService.getProblemsBycheckId(checkId);
    }

    @ResponseBody
    @PostMapping("/getProblemsByContractId")
    public  List<Object> getProblemsByContractId(Integer contractId){
        return motorService.getProblemsByContractId(contractId);
    }

    @ResponseBody
    @PostMapping("/getAllContractInfo")
    public  List<Object> getAllContractInfo(){
        return motorService.getAllContractInfo();
    }

    @ResponseBody
    @PostMapping("/getAllProjectInfo")
    public  List<ContractTaskProject> getAllProjectInfo(){
        return motorService.getAllProjectInfo();
    }

    @ResponseBody
    @PostMapping("/getProjectInfoByContractId")
    public  List<Problemcollect> getProjectInfoByContractId(Integer contractId,Integer firstId){
        return motorService.getProjectInfoByContractId(contractId,firstId);
    }

    @ResponseBody
    @PostMapping("/getTimeInterval")
    public  Problemcollect getTimeInterval(Integer contractId,Integer firstId){
        return motorService.getTimeInterval(contractId,firstId);
    }

    /**
     * @Author chenhuanru
     * @Description //根据委托方id查询委托方名称
     * @Date 19:28 2020/3/16
     * @Param [contractId]
     * @return java.lang.String
     **/

    @ResponseBody
    @PostMapping("/getClientByContractId")
    public Contractinfo getClientByContractId(Integer contractId){
        return motorService.getClientByContractId(contractId);
    }

    /*wxd-根据行政区域查询委托方及其项目个数*/
    @ResponseBody
    @PostMapping("/getProjectNumByArea")
    public List<ProjectNum> getProjectNumByArea(String area){
        return motorService.getProjectNumByArea(area);
    }

    /*wxd-根据委托方名字查询项目坐标*/
    @ResponseBody
    @PostMapping("/getProjectLocByContractIds")
    public Object getProjectLocByContractIds(String contractIds) { return  motorService.getProjectLocByContractIds(contractIds);}

    /*wxd-根据委托方ID查询所需项目信息(项目名称\项目类型\最近一次检查时间\经纬度\最近一次检查分数)*/
    @ResponseBody
    @PostMapping("/getCTPInfoByContractId")
    public List<CTPInfo> getCTPInfoByContractId (Integer contractId){ return motorService.getCTPInfoByContractId(contractId);}
    /**
     * @Author chenhuanru
     * @Description //测试获取所有第四级问题
     * @Date 12:09 2020/4/14
     * @Param [contractIds]
     * @return java.util.List<java.lang.Object>
     **/

    @ResponseBody
    @PostMapping("/getDataTest")
    public List<Object> getDataTest(String secondName,String contractIds){
        return motorService.getDataTest(secondName,contractIds);
    }

    /**
     * @Author chenhuanru
     * @Description //获取项目所有问题
     * @Date 15:50 2020/5/21
     * @Param [projectId]
     * @return java.util.List<com.whut.v_model.ProblemCollectDetail>
     **/

    @ResponseBody
    @PostMapping("/getProblemDetail")
    public List<ProblemCollectDetail> getProblemDetail(int projectId,String reserve1){
        return motorService.getProblemDetail(projectId,reserve1);
    }

   /**
    * @Author chenhuanru
    * @Description //根据片区获取问题信息
    * @Date 13:41 2020/5/30
    * @Param [taskId]
    * @return java.util.List<com.whut.v_model.ProblemCollectDetail>
    **/

    @ResponseBody
    @PostMapping("/getProblemsByTaskId")
    public List<ProblemCollectDetail> getProblemsByTaskId(int taskId){
        return motorService.getProblemsByTaskId(taskId);
    }


}
